home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / src / Range / Base_Range.h < prev    next >
C/C++ Source or Header  |  1992-04-13  |  3KB  |  72 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. //
  13. // Created: MBN 09/01/89 -- Initial design and implementation
  14. // Updated: LGO 12/04/89 -- Efficiency re-write
  15. // Updated: MJF 07/31/90 -- Added terse print
  16. // Updated: DLS 03/27/91 -- New lite version
  17. //
  18. // The  CoolRange class implements non-type specific  common  functionality for the
  19. // parameterized CoolRange<Type>. In this manner, code replication is  reduced. The
  20. // CoolRange<Type> class  supports  arbitrary user-defined ranges  for  a  type  of
  21. // object or built-in data type. This allows other higher level data structures
  22. // such as Vector to be parameterized over a  range of values  for some type so
  23. // that   the  programmer  does  not have  to add  bounds  checking code to the
  24. // application.  A Vector of positive integers, for  example, would be  easy to
  25. // declare, facilitating bounds checking restricted to the code that implements
  26. // the type, not the vector.
  27. //
  28. // The inclusive upper and lower bounds for the range are stored in two private
  29. // static data slots for the class as a  whole.  In addition, a single instance
  30. // private  data slot holds the instance  value. There are  three constructors.
  31. // The first is a simple  empty constructor. The second  is a constructor  that
  32. // also accepts an  initial value. And the third  is a constructor that takes a
  33. // reference to another CoolRange<Type> object and copies the value.
  34. //
  35. // All methods are implemented as  small inline  functions to provide efficient
  36. // encapsulation of objects, including built-in types such as  int. Methods are
  37. // provided to set and get the lower and upper bounds for the  class as a whole
  38. // and set the  value of the  instance data  slot. Assignment of  one object to
  39. // another is supported by the overloaded operator=  methods.  Operator() is an
  40. // inline  method to  return  the value of  the  instance  object.  Finally, an
  41. // implicit conversion from a CoolRange<Type> object to a Type value is provided to
  42. // allow for mixed expressions.
  43. //
  44.  
  45. #ifndef BASE_RANGEH                // If no CoolRange class
  46. #define BASE_RANGEH
  47.  
  48. #ifndef STREAMH            // If the Stream support not yet defined,
  49. #if defined(DOS) || defined(M_XENIX)
  50. #include <stream.hxx>        // include the Stream class header file
  51. #else
  52. #include <stream.h>        // include the Stream class header file
  53. #endif
  54. #define STREAMH
  55. #endif
  56.  
  57. #define MSG_MAX 256
  58.  
  59.  
  60. class CoolRange {
  61. protected:
  62.   static char msg_buffer[MSG_MAX];
  63.  
  64.   CoolRange() {};                    // Protected constructor
  65.   void set_low_error (const char*, const char*, const char*, const char*) const;
  66.   void set_upper_error (const char*,  const char*, const char*, const char*) const; 
  67. public:
  68.   void print(ostream&);                         // terse print
  69. };
  70.  
  71. #endif                        // End #ifdef of BASE_RANGEH
  72.